var _url = '../';
$(function(){
	setTimeout(function(){
		var cityId = $('#cityId').val();
		jQuery.each(jQuery("input[name='city']"), function(){
            if (cityId != '' && $(this).val() == cityId) {
                $(this).attr("checked",'checked');;
				return;
            }
        });
        
		if(cityId == 2) {
//			$("#danyuan").combobox('disable'); 
		}
		
		var bedroomSum = $('#bedroomSum').val();
		var data = $('#shiP').combobox('getData');
		for(var i=0; i<data.length;i++) {
			if(data[i].id==bedroomSum){
				$('#shiP').combobox('select',data[i].id);
			}
		}
		
		var livingRoomSum = $('#livingRoomSum').val();
		var data = $('#tingP').combobox('getData');
		for(var i=0; i<data.length;i++) {
			if(data[i].id==livingRoomSum){
				$('#tingP').combobox('select',data[i].id);
			}
		}
		
		var wcSum = $('#wcSum').val();
		var data = $('#weiP').combobox('getData');
		for(var i=0; i<data.length;i++) {
			if(data[i].id==wcSum){
				$('#weiP').combobox('select',data[i].id);
			}
		}
		
		var building = $('#building').val();
		var b_arr = new Array();
		if(building != "") {
			b_arr = building.split("-")
		}
		
		if(b_arr.length > 0) {
			$('#loudong').combobox('setValue',b_arr[0]);
		}
		if(b_arr.length == 2) {
//			$('#danyuan').combobox('setValue',b_arr[1]);
		}			
	},200);	
});

//重查小区
function reQueryXiaoqu() {
	jQuery("#addr").combobox("clear");
    $("#estateText").val("");
    $("#estateValue").val("");
	jQuery("#loudong").combobox("clear");
	$("#loudong").combobox("enable");
//	jQuery("#danyuan").combobox("clear");
	jQuery("#shihao").textbox("clear");
	
	var cb = "";
    $('input[name="cb"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数    
    	$(this).removeAttr("checked"); 
    	$(this).removeAttr("disabled"); 
    });
    
    var cityId = "";
	jQuery.each(jQuery("input[name='city']"), function(){
        if ($(this).is(":checked")) {
            cityId = $(this).val();
            return;
        }
    });
	
//	if(cityId == 2) {
//		$("#danyuan").combobox('disable');
//	} else {
//		$("#danyuan").combobox('enable');
//	}
}

//切换城市做相关操作
function changeCity() {
	$($("#pannelForm").find("input[id='xiaoqu']")).val("");
    
	reQueryXiaoqu();
	getPriceRegion();
}

//获取价格范围
function getPriceRegion() {
	var cityId = "";
	jQuery.each(jQuery("input[name='city']"), function(){
        if ($(this).is(":checked")) {
            cityId = $(this).val();
            return;
        }
    });
	var params = {'ht' : 1, 'cityId' : cityId};
	jQuery.ajax({
        url:_url + "getPriceRegion.json",
        data:params,
        type:"post",
        dataType:"json",
        async:false,
        success:function(result) {
            if (result.code == 1) {
				$('#minPrice').val(result.data.minPrice);
                $('#maxPrice').val(result.data.maxPrice);
                return;
            } 
        }
    });
}

//提交房源信息
function resetForm() {
    $("#estateText").val("");
    $("#estateValue").val("");
    $("#pannelForm").form("reset");
    }
   
    //点击提交
    function onOk() {
        var flag = validatePannelForm();
        if (!flag)
            return;
        jQuery("#submitForm").linkbutton("disable");
	    var params = takePannelFormData();
	
		jQuery.ajax({
	        url:_url + "submitHouseforSelf.json",
	        data:params,
	        type:"post",
	        dataType:"json",
	        async:false,
	        success:function(result) {
	            if (result.code == 1) {
	                jQuery.messager.alert("提示", "提交成功", "info", function(){  
	                	window.location.href=_url + "renthouse/addRent2.do";  
	                });
	                return;
	            } else if(result.code == 4000011 || result.code == 4000014 || result.code == 4000016) {
	            	jQuery.messager.alert("提示", result.message, "info", function(){  
	                	//window.location.href=_url + "checkhouse/checklist.do";  
	                });
	            	return;
	            } else {
	                jQuery.messager.alert("警告", result.message, "error");
	                return;
	            }
	
	        }
	    });
	}

//表单验证
function validatePannelForm() {
	var cityId = "";
	jQuery.each(jQuery("input[name='city']"), function(){
        if ($(this).is(":checked")) {
            cityId = $(this).val();
            return;
        }
    });
    var xiaoqu = $($("#pannelForm").find("input[id='estateValue']")).val();
    var addr = jQuery("#addr").combobox("getValue");
    var loudong = "";
    if (jQuery("#loudong").combobox("getData").length > 0) {
        loudong = jQuery("#loudong").combobox("getValue");
    } else {
        loudong = jQuery("#loudong").combobox("getText");
    }
    var shihao = jQuery("#shihao").textbox("getValue");
	
    var shoujia = jQuery("#price").numberbox("getValue");
	var maxPrice = $("#maxPrice").val();
	var minPrice = $("#minPrice").val();
	
    var mianji = jQuery("#mianji").textbox("getValue");
    var shiP = jQuery("#shiP").combobox("getValue");
    var tingP = jQuery("#tingP").combobox("getValue");
    var weiP = jQuery("#weiP").combobox("getValue");
    var fangdongname = jQuery("#fangdongname").textbox("getValue");
    var fangdongphone = jQuery("#fangdongphone").textbox("getValue");
    var laidian = "";
	if($("#laidian").length > 0) {
		laidian = jQuery("#laidian").textbox("getValue")
	}
	
	var memo = jQuery("#memo").textbox("getValue");
	
	if (cityId == "") {
		jQuery.messager.alert("错误", "请选择城市!", "error");
        return false;
	}
    if (xiaoqu == "") {
        jQuery.messager.alert("错误", "请选择小区!", "error");
        return false;
    }
	
    if (!jQuery("#addrSpan").is(":hidden") && addr == "") {
        jQuery.messager.alert("错误", "请选择子划分!", "error");
        return false;
    }
    if (loudong == "") {
    	var cb = "";
        $('input[name="cb"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数    
        	var tmp = $(this).val();
			if(tmp == 1){
				cb = tmp;
			}
        });
		if(cb == "") {
	        jQuery.messager.alert("错误", "请选择或输入楼栋!", "error");
	        return false;
		}
    }
    
    if (shihao == "") {
		var cb = "";
        $('input[name="cb"]:checked').each(function(){//遍历每一个名字为interest的复选框，其中选中的执行函数    
        	var tmp = $(this).val();
			if(tmp == 2){
				cb = tmp;
			}
        });
		if(cb == "") {
            jQuery.messager.alert("错误", "请输入室号!", "error");
            return false;
		}
    }
	if (shiP == "") {
        jQuery.messager.alert("错误", "请选择室数!", "error");
        return false;
    }
    if (tingP == "") {
        jQuery.messager.alert("错误", "请选择厅数!", "error");
        return false;
    }
    if (weiP == "") {
        jQuery.messager.alert("错误", "请选择卫数!", "error");
        return false;
    }
	
	if (mianji == "") {
        jQuery.messager.alert("错误", "请输入面积!", "error");
        return false;
    }
    if (!/^\d+(.\d{1,2})?$/.test(mianji)) {
        jQuery.messager.alert("错误", "面积请输入数字，请勿超过两位小数!", "error");
        return false;
    }
    
    if(mianji < 0 || mianji > 10000 ){
    	jQuery.messager.alert("错误", "面积区间在：0-10000平米", "error");
        return false;
    }

	if (shoujia == "") {
        jQuery.messager.alert("错误", "请输入正确的租金!", "error");
        return false;
    }
	shoujia = parseInt(shoujia);
	if (maxPrice != "" && minPrice != "" && (shoujia > maxPrice || shoujia < minPrice)) {
		jQuery.messager.alert("错误", "租金区间在：" + minPrice + "-" + maxPrice + " 元/月", "error");
        return false;
	}
	
    if (fangdongname == "" || fangdongname.length > 15 || fangdongname.length < 2) {
        jQuery.messager.alert("错误", "请输入房东姓名!", "error");
        return false;
    }
    if (fangdongphone == "") {
        jQuery.messager.alert("错误", "请输入房东手机号!", "error");
        return false;
    }
	if (!/^[0-9\-]{6,16}$/.test(fangdongphone)) {
		jQuery.messager.alert("错误", "房东手机号格式不对!", "error");
        return false;
	}
	
	if($("#laidian").length > 0 && laidian == "" ) {
		jQuery.messager.alert("错误", "来电号码必须填写!", "error");
        return false;
	}
	
	if (laidian != "" && !/^[0-9\-]{6,16}$/.test(laidian)) {
		jQuery.messager.alert("错误", "来电号码格式不对!", "error");
        return false;
	}
	
	if(memo.length > 100) {
		 jQuery.messager.alert("错误", "备注只能输入100个字!", "error");
	     return false;
	}
	
	
    return true;
}

function takePannelFormData() {
	var fangdongname = jQuery("#fangdongname").textbox("getValue");
    var fangdongphone = jQuery("#fangdongphone").textbox("getValue");
    var gender = "";
	jQuery.each(jQuery("input[name='gender']"), function(){
        if ($(this).is(":checked")) {
        	gender = $(this).val();
            return;
        }
    });
	
	var cityId = "";
	jQuery.each(jQuery("input[name='city']"), function(){
        if ($(this).is(":checked")) {
            cityId = $(this).val();
            return;
        }
    });
    var xiaoqu = $($("#pannelForm").find("input[id='estateValue']")).val();
    var addr = jQuery("#addr").combobox("getValue");
   
    var loudong = "";
    if (jQuery("#loudong").combobox("getData").length > 0) {
        loudong = jQuery("#loudong").combobox("getValue");
    } else {
        loudong = jQuery("#loudong").combobox("getText");
    }
    var shihao = jQuery("#shihao").textbox("getValue");
    
    var cb = [];
    $('input[name="cb"]:checked').each(function(){// 遍历每一个名字为interest的复选框，其中选中的执行函数
    	var tmp = $(this).val();
    	cb.push(tmp);// 将选中的值添加到数组
    	if(tmp == 1) {
    		loudong = "0";
    	} else if(tmp ==2) {
    		shihao = "0000";
    	}
    });
    
    var building = loudong;
    
    var shoujia = jQuery("#price").numberbox("getValue");
    var mianji = jQuery("#mianji").textbox("getValue");
    var shiP = jQuery("#shiP").combobox("getValue");
    var tingP = jQuery("#tingP").combobox("getValue");
    var weiP = jQuery("#weiP").combobox("getValue");
	var memo = jQuery("#memo").textbox("getValue");
	
	var source = $('#source').val();
	if(source == "") source = 1;
	
	var delegationId = $('#delegationId').val();
	if(delegationId == "") delegationId = 0;
	
	var estateName = $($("#pannelForm").find("input[id='estateText']")).val()
	var subEstateName = jQuery("#addr").combobox("getText");

    return {cityId : cityId, houseType : 1, orderType : 1, source : source, estateId : xiaoqu, subEstateId : addr, building : building, room : shihao, price : shoujia, spaceArea : mianji, bedroomSum : shiP,
        livingRoomSum : tingP, wcSum : weiP, hostName : fangdongname, houstMobile : fangdongphone, gender : gender, memo : memo, cb: cb, delegationId : delegationId
        , estateName : estateName, subEstateName : subEstateName, who : 1};
}

$(document).ready(function(){
	initCity();
	initXiaoQuSearch();
	
	var frm=$('#pannelForm');
	var pa=frm.find('.Pa');
	$("#xiaoqu").focus(function(){
		var key = $('#xiaoqu').val();
		if(key == "") return;
		queryXiaoQu(key,0);
	});
});

//初始化城市
function initCity(){
	new jQuery.ajax({
        url:_url + 'getAllCity.json',
        cache:false,
        type:'post',
        success:function(data){
        	if(data == '') return;
        	var html = "";
        	for(var i = 1; i < data.length; i++) {
        		html = html + "<input type='radio' name='city' value='" + data[i].id + "' onclick='changeCity()'/><span>" + data[i].text + "</span>　";  
        	}
        	$('#citySpan').html(html);
        }
    });
}

function initXiaoQuSearch() {
    var frm=$('#pannelForm');
    var searchName = frm.find('[name=estateName]');//搜索关键字

	var pa=frm.find('.Pa');
    var kww=frm.find('.kww');
    if(pa.length==0)pa=$('<p class="Pa">estate list is null</p>').prependTo(kww);
	
    searchName.blur(function(){
        setTimeout(function(){pa.hide()},200);
    });

    searchName.keyup(function(e) {//关键字输入
        var self=$(this);
        var k=e.keyCode;
        if(k==27||k==35||k==36||k==37||k==38||k==39||k==40||k==13)return;//忽略ESE 上 下 左 右键 回车
        var key=Val(self);
        $($("#pannelForm").find("input[id='estateValue']")).val("");
        $($("#pannelForm").find("input[id='estateText']")).val(key);
        
        //如小区名为空,则清空子划分和栋
        //if (key == null || key == "") {
            var array = new Array();
            jQuery("#addr").combobox("reset");
            jQuery("#addr").combobox("loadData", array);
            jQuery("#loudong").combobox("reset");
            jQuery("#loudong").combobox("loadData", array);
        //}
        if(key==self.attr('key')){//防止相同内容多次查询
            return;
        }else{
            self.attr('key',key);
        };
        if(key==''){
            pa.html('').hide();
            self.focus();
            return;
        };
        if(this.Ajax)this.Ajax.abort();//取消上次查询
		
        this.Ajax=queryXiaoQu(key,1);
    });
}

//查小区
function queryXiaoQu(key,flag) {
	reQueryXiaoqu();
	var self=$('#xiaoqu');
 	var frm=$('#pannelForm');
	var pa=frm.find('.Pa');
	var cityId = 0;
	var chkObjs = document.getElementsByName("city");
    for(var i=0;i<chkObjs.length;i++){
        if(chkObjs[i].checked){
            cityId = chkObjs[i].value;
            break;
        }
    }
	if(cityId == 0){
		alert("请先选择城市！");
		return;
	}
	new jQuery.ajax({
            url:_url + 'queryXiaoQu.json',
            cache:false,
            type:'post',
            dataType:'json',
            data:{cityId:cityId,q:key},
            success:function(d){
                if(d.code == "1"){
                    if(d.data && d.data.length==0){
                        pa.html('').hide();
                        if(flag == 1)jQuery.messager.alert("", "No Results", "error");
                    }else{
                        pa.html('');
                        var reg=new RegExp('('+key+')','gi'),tit,span;
                        $(d.data).each(function(_,i){
                            if(!i.id)return;
                            tit='';
                            span=i.text;
                            $('<a href="javascript:"'+tit+'><span id="'+i.id+'">'+span.replace(reg,'<b>$1</b>')+'</span></a>')
                                    .click(function(){
                                        self.val(i.text);
                                        $($("#pannelForm").find("input[id='estateValue']")).val(i.id);
                                        $($("#pannelForm").find("input[id='estateText']")).val(i.text);
                                        var reg=new RegExp('('+i.text+')');
                                        pa.find('a').each(function(_,i){
                                            i.className="";
                                            i=$(i);
                                            i.find('span').html(i.find('span').text().replace(reg,'<b>$1</b>'));
                                        });
                                        $(this).addClass('act');
                                        pa.hide();
                                        //初始化子划分
                                        initSubEstates(i.id);
                                    }).appendTo(pa);
                        });
                        pa.show();
                    };
                };
            },
            error:function(){
                pa.hide();
            }
        });
}

$(document).click(function(e){
    var SearchPa=$('#pannelForm .Pa');
    if(SearchPa.is(':visible')&&e.target.name!=('estateName')){
		SearchPa.hide();
	}
}).keydown(function(e){
    //预搜索按键
    if($('#pannelForm .Pa').is(":visible")){
        var SearchPa=$('#pannelForm .Pa');
        var oneH=SearchPa[0].scrollHeight/SearchPa.find('a').length;//一项的高度
        var maxHc=SearchPa.height()/oneH;//div能显示的最多的项数
        var scrollTop;

        var kc=e.keyCode;//按键Code
        if(kc==27||kc==13){//ESC|回车
            SearchPa.hide();
        }else if(kc==38||kc==40){//上|下
            SearchPa.act=-1;
            SearchPa.a=SearchPa.find("a");
            for(var i=SearchPa.a.length-1;i>=0;i--){
                if(SearchPa.a.eq(i).hasClass('act')){
                    SearchPa.act=i;
                    break;
                };
            };
            if(kc==38){//上
                if(SearchPa.act<=0){
                    SearchPa.act=0;
                }else{
                    SearchPa.act--;
                };
                if(SearchPa.act>maxHc-1){
                    scrollTop=SearchPa.scrollTop()-oneH;
                }
            }else if(kc==40){//下
                if(SearchPa.act<0){
                    SearchPa.act=0;
                }else{
                    if(SearchPa.act<SearchPa.a.length-1) SearchPa.act++;
                };
                if(SearchPa.act>maxHc && SearchPa.act<SearchPa.a.length){
                    scrollTop=SearchPa.scrollTop()+oneH;
                }
            };
            SearchPa.scrollTop(scrollTop);

            var txt=SearchPa.a.eq(SearchPa.act).attr('title');
            if(!txt)txt=SearchPa.a.eq(SearchPa.act).find('span').text();
            var id=SearchPa.a.eq(SearchPa.act).find('span').attr("id");
            $("#pannelForm").find("input[id='estateValue']").val(id);
            $("#pannelForm").find("input[id='estateText']").val(txt);
            //初始化子划分
            initSubEstates(id);
            $("#pannelForm input[name='kw']").val(txt);
            var reg=new RegExp('('+txt+')');
            SearchPa.a.each(function(_,i){
                i.className="";
                i=$(i);
                i.find('span').html(i.find('span').text().replace(reg,'<b>$1</b>'));
            });
            SearchPa.a.eq(SearchPa.act).addClass('act');
        };
    };
});

//初始化栋号
function initBuilding(subEstateId) {
    var obj = new Array();
    var danyuan_arr = new Array();
    jQuery.ajax({
        url:_url + "getBuildingInfo.json",
        data:"subEstateId=" + subEstateId,
        dataType:"json",
        type:"post",
        async:false,
        success: function (result) {
			if(result.data == null) {
				var cb_arr=document.getElementsByName("cb");
                for(var i=0;i<cb_arr.length;i++){
					if(cb_arr[i].value == 1){
                  		cb_arr[i].disabled=true;
					}
                }
			} else {
				var cityId = "";
				jQuery.each(jQuery("input[name='city']"), function(){
			        if ($(this).is(":checked")) {
			            cityId = $(this).val();
			            return;
			        }
			    });
				
//				var danyuan_boolean = true;
//				if(cityId == 2) {
//					danyuan_boolean = false;
//				} 
				
                if (result.data.lockStatus == null || result.data.lockStatus == 1) {//未锁定
					var cb_arr=document.getElementsByName("cb");
                    for(var i=0;i<cb_arr.length;i++){
						if(cb_arr[i].value == 1){
                      		cb_arr[i].disabled=false;
						}
                    }
					 
                    initLoudong(obj, true);
                    //initDanYuan(danyuan_arr, danyuan_boolean);
                    $("#loudong").combobox('enable');
                    
                } else if (result.data.lockStatus == 2) {//锁定
					var cb_arr=document.getElementsByName("cb");
                    for(var i=0;i<cb_arr.length;i++){
						if(cb_arr[i].value == 1){
                      		cb_arr[i].checked=true;
						}
                    }
					obj.push({"id" : "0", "text" : "独栋"});
                    initLoudong(obj, false);
                    //initDanYuan(danyuan_arr, false);
                    $("#loudong").combobox('disable');
                    $("#dudong").attr('disabled', 'disabled');
                } else if (result.data.lockStatus == 3) {
                    for (var i = 0; i < result.data.buildingList.length; i ++) {
                        var building = result.data.buildingList[i];
                        
                        var b_arr = new Array();
                        b_arr = building.buildingName.split("-");
                        if(b_arr.length > 0) {
                        	obj.push({"id" : building.buildingName, "text" : building.buildingName});
                		}
                    }
                    initLoudong(obj, false);
                    //initDanYuan(danyuan_arr, danyuan_boolean);
                    $("#dudong").attr('disabled', 'disabled');
                }
			}
        }
    });
}

//初始化楼栋信息
function initLoudong(data, editable) {
    var params;
    if (editable) {
        params = {hasDownArrow:false,panelHeight:'auto'};
    } else {
        if (data.length < 10)
            params = {hasDownArrow:true, panelHeight:'auto'};
        else
            params = {hasDownArrow:true, panelHeight:'200'};

    }
    jQuery("#loudong").combobox(params);
    jQuery("#loudong").combobox({
        valueField:'id',
        textField:'text',
        editable : editable,
        data:data,
        onLoadSuccess: function () {
            if (data.length > 0) {
                var loudongData = jQuery("#loudong").combobox("getData");
                if (loudongData.length > 0) {
                    jQuery("#loudong").combobox("select", loudongData[0].id);
                }
            }
        }
    });
}
//初始化单元信息
function initDanYuan(data, editable) {
    var params;
    if (editable) {
        params = {hasDownArrow:false,panelHeight:'auto'};
    } else {
        if (data.length < 10)
            params = {hasDownArrow:true, panelHeight:'auto'};
        else
            params = {hasDownArrow:true, panelHeight:'200'};

    }
    jQuery("#danyuan").combobox(params);
    jQuery("#danyuan").combobox({
        valueField:'id',
        textField:'text',
        editable : editable,
        data:data,
        onLoadSuccess: function () {
            if (data.length > 0) {
                var loudongData = jQuery("#danyuan").combobox("getData");
                if (loudongData.length > 0) {
                    jQuery("#danyuan").combobox("select", loudongData[0].id);
                }
            }
        }
    });
}

//子划分
function initSubEstates(xiaoquId) {
    jQuery("#addr").combobox({
        valueField:'id',
        textField:'text',
        method:'get',
        panelHeight:'auto',
        editable : false,
        url:_url + "querySubEstates.json?estateId=" + xiaoquId,
        prompt:'选择地址',
        onLoadSuccess: function () {
            var data = jQuery("#addr").combobox("getData");
            var estateValue = $($("#pannelForm").find("input[id='estateValue']")).val();
            if (data.length == 1 && estateValue != "" && estateValue != null) {
                if (data[0].text == null || data[0].text == '') {
                    jQuery("#addr").combobox("select", data[0].id);
                    jQuery("#addrSpan").hide();
                    return;
                }
            }
            if (data.length > 0 && estateValue != "" && estateValue != null){
                jQuery("#addrSpan").show();
                jQuery("#addr").combobox("select", data[0].id);
            }
        },
        onSelect: function (rec) {
            initBuilding(rec.id);
        }
    });
}

function initXiaoQuValueChange() {
    $($("#pannelForm").find("input[id='estateValue']")).change(function () {
       var val = $(this).val();
        if (val == null || val == "") {
            var array = new Array();
            jQuery("#addr").combobox("reset");
            jQuery("#addr").combobox("loadData", array);
            jQuery("#loudong").combobox("reset");
            jQuery("#loudong").combobox("loadData", array);
        } else {
            initSubEstates(val);
        }
    });

}

function initShiTingWeiSelect() {
    var shiData = jQuery("#shiP").combobox("getData");
    var tingData = jQuery("#tingP").combobox("getData");
    var weiData = jQuery("#weiP").combobox("getData");
    if (shiData.length > 0) {
        jQuery("#shiP").combobox("select", shiData[0].id);
    }
    if (tingData.length > 0) {
        jQuery("#tingP").combobox("select", tingData[0].id);
    }
    if (weiData.length > 0) {
        jQuery("#weiP").combobox("select", weiData[0].id);
    }
}

function selectedBieshu(){
	jQuery("#shihao").textbox("clear");

	if($('#bieshu').attr("checked")){
		$("#shihao").combobox('disable'); 
	} else {
		$("#shihao").combobox('enable'); 
	}
}

//改变了手机、性别、姓名
function changeConfirmInfo(){
	jQuery('#confirmSpan').css("display","block");
	jQuery('#hosueSpan').css("display","none");
}

//点击确认
function toConfirm() {
	var fangdongname = jQuery("#fangdongname").textbox("getValue");

	var gender = "";
    jQuery.each(jQuery("input[name='gender']"), function(){
        if ($(this).is(":checked")) {
            gender = $(this).val();
            return;
        }
    });
    
	var fangdongphone = jQuery("#fangdongphone").textbox("getValue");
	
	if (fangdongname == "" || fangdongname.length > 15 || fangdongname.length < 2) {
        jQuery.messager.alert("错误", "请输入房东的真实姓名！", "error");
        return false;
    }
	
    if (gender == "") {
        jQuery.messager.alert("错误", "请选择性别!", "error");
        return false;
    }
	
    if (fangdongphone == "") {
        jQuery.messager.alert("错误", "请输入房东手机号!", "error");
        return false;
    }
	if (!/^[0-9\-]{6,16}$/.test(fangdongphone)) {
		jQuery.messager.alert("错误", "房东手机号格式不对!", "error");
        return false;
	}

	var params = {mobile : fangdongphone, houseType : 1, who : 1, landlordName:fangdongname, landlordGender: gender};
	
	jQuery.ajax({
    url:_url + "checkMobile.json",
    data:params,
    type:"post",
    dataType:"json",
    async:false,
    success:function(result) {
        if (result.code == 1) {
            jQuery('#confirmSpan').css("display","none");
			jQuery('#hosueSpan').css("display","block");
        } else {
            jQuery.messager.alert("警告", result.message, "error");
            return;
        }

    }
	});
}